package com.heqiang.spring.aop.framework;

import com.heqiang.spring.aop.AdvisedSupport;

public class ProxyFactory {

    private AdvisedSupport support;

    public ProxyFactory(AdvisedSupport support) {
        this.support = support;
    }

    public Object getProxy() {
        return creatAopProxy().getProxy();
    }

    private AopProxy creatAopProxy() {
        if (support.isProxyTargetClass()) {
            return new Cglib2AopProxy(support);
        }
        return new JdkDynamicAopProxy(support);
    }
}
